package com.yan.controller;


import com.baomidou.kisso.SSOHelper;
import com.baomidou.kisso.Token;
import com.jfinal.aop.Before;
import com.jfinal.core.Controller;
import com.yan.annon.RouterMapping;
import com.yan.intercepter.SSOJFinalInterceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by yanl_ on 2018/3/9.
 */

@Before(SSOJFinalInterceptor.class)
@RouterMapping(url = "/testIndex", viewPath = "/")
public class TestIndexController extends Controller {

    private static final Logger log = LoggerFactory.getLogger(IndexController.class);

    public void index() {
        log.info("进入主页!");
        //从request中拿到token
        Token token = SSOHelper.attrToken(getRequest());
        if (token != null) {
            log.info("登陆令牌UID" + token.getUid());
            log.info("登陆令牌IP地址" + token.getIp());
            render("/index.html");
            return;
        }
        render("login.jsp");
    }

}
